package system.data;

import java.util.*;

import framework.core.*;

/*
 Author    :Jackey
 CreateTime:2008-03-03 10:07:46
 */
public class ProductUpdatePriceBase extends Table {
	public static final String TABLE_NAME = "T_PRODUCT_UPDATE_PRICE";

	private static final String BACKUP_TABLE_NAME = "T_PRODUCT_UPDATE_PRICE_BACKUP";

	private static final String BACKUP_SEQ_NAME = "S_PRODUCT_UPDATE_PRICE_BACKUP";

	public static final String ID = "ID";

	public static final String PRODUCT_ID = "PRODUCT_ID";

	public static final String CONCENTRICITY_CODE = "CONCENTRICITY_CODE";

	public static final String BEFORE_PRICE = "BEFORE_PRICE";

	public static final String AFTER_PRICE = "AFTER_PRICE";

	public static final String CREATE_USER_ID = "CREATE_USER_ID";

	public static final String CREATE_USER = "CREATE_USER";

	public static final String CREATE_TIME = "CREATE_TIME";

	public static final String AUDITING_USER_ID = "AUDITING_USER_ID";

	public static final String AUDITING_USER = "AUDITING_USER";

	public static final String AUDITING_TIME = "AUDITING_TIME";

	public static final String AUDITING_STATUS = "AUDITING_STATUS";

	public static final String ENABLED_TIME = "ENABLED_TIME";

	public static final String STATUS = "STATUS";

	public static Vector m_fields = null;

	private String m_id = ""; // 序号

	private String m_product_id = ""; // 产品ID

	private String m_concentricity_code = "";// 产品集中编码

	private double m_before_price = Value.NULL_DOUBLE; // 调价前价格

	private double m_after_price = Value.NULL_DOUBLE; // 调价后价格

	private String m_create_user_id = ""; // 创建人序号

	private String m_create_user = ""; // 创建人

	private String m_create_time = ""; // 创建时间

	private String m_auditing_user_id = ""; // 审批人序号

	private String m_auditing_user = ""; // 审批人

	private String m_auditing_time = ""; // 审批时间

	private String m_auditing_status = ""; // 审批状态

	private String m_enabled_time = ""; // 启用时间

	private String m_status = ""; // 是否有效

	public String getId() {
		return m_id;
	}

	public void setId(String v) {
		if (getId().equals(v))
			return;
		m_id = v;
		markDirty(ID);
	}

	public String getProductId() {
		return m_product_id;
	}

	public void setProductId(String v) {
		if (getProductId().equals(v))
			return;
		m_product_id = v;
		markDirty(PRODUCT_ID);
	}

	public String getConcentricityCode() {
		return m_concentricity_code;
	}

	public void setConcentricityCode(String v) {
		if (getConcentricityCode().equals(v))
			return;
		m_concentricity_code = v;
		markDirty(CONCENTRICITY_CODE);
	}

	public double getBeforePrice() {
		return m_before_price;
	}

	public void setBeforePrice(double v) {
		if (getBeforePrice() == v)
			return;
		m_before_price = v;
		markDirty(BEFORE_PRICE);
	}

	public double getAfterPrice() {
		return m_after_price;
	}

	public void setAfterPrice(double v) {
		if (getAfterPrice() == v)
			return;
		m_after_price = v;
		markDirty(AFTER_PRICE);
	}

	public String getStatus() {
		return m_status;
	}

	public void setStatus(String v) {
		if (getStatus().equals(v))
			return;
		m_status = v;
		markDirty(STATUS);
	}

	public String getCreateUserId() {
		return m_create_user_id;
	}

	public void setCreateUserId(String v) {
		if (getCreateUserId().equals(v))
			return;
		m_create_user_id = v;
		markDirty(CREATE_USER_ID);
	}

	public String getCreateUser() {
		return m_create_user;
	}

	public void setCreateUser(String v) {
		if (getCreateUser().equals(v))
			return;
		m_create_user = v;
		markDirty(CREATE_USER);
	}

	public String getCreateTime() {
		return m_create_time;
	}

	public void setCreateTime(String v) {
		if (getCreateTime().equals(v))
			return;
		m_create_time = v;
		markDirty(CREATE_TIME);
	}

	public String getAuditingUserId() {
		return m_auditing_user_id;
	}

	public void setAuditingUserId(String v) {
		if (getAuditingUserId().equals(v))
			return;
		m_auditing_user_id = v;
		markDirty(AUDITING_USER_ID);
	}

	public String getAuditingUser() {
		return m_auditing_user;
	}

	public void setAuditingUser(String v) {
		if (getAuditingUser().equals(v))
			return;
		m_auditing_user = v;
		markDirty(AUDITING_USER);
	}

	public String getAuditingTime() {
		return m_auditing_time;
	}

	public void setAuditingTime(String v) {
		if (getAuditingTime().equals(v))
			return;
		m_auditing_time = v;
		markDirty(AUDITING_TIME);
	}

	public String getAuditingStatus() {
		return m_auditing_status;
	}

	public void setAuditingStatus(String v) {
		if (getAuditingStatus().equals(v))
			return;
		m_auditing_status = v;
		markDirty(AUDITING_STATUS);
	}

	public String getEnabledTime() {
		return m_enabled_time;
	}

	public void setEnabledTime(String v) {
		if (getEnabledTime().equals(v))
			return;
		m_enabled_time = v;
		markDirty(ENABLED_TIME);
	}

	public String viewId(DBConnection con) throws Exception {
		return Value.view(getId());
	}

	public String viewProductId(DBConnection con) throws Exception {
		return Value.view(getProductId());
	}

	public String viewConcentricityCode(DBConnection con) throws Exception {
		return Value.view(getConcentricityCode());
	}

	public String viewBeforePrice(DBConnection con) throws Exception {
		return Value.view(getBeforePrice());
	}

	public String viewAfterPrice(DBConnection con) throws Exception {
		return Value.view(getAfterPrice());
	}

	public String viewCreateUserId(DBConnection con) throws Exception {
		return Value.view(getCreateUserId());
	}

	public String viewCreateUser(DBConnection con) throws Exception {
		return Value.view(getCreateUser());
	}

	public String viewCreateTime(DBConnection con) throws Exception {
		return Value.view(getCreateTime());
	}

	public String viewAuditingUserId(DBConnection con) throws Exception {
		return Value.view(getAuditingUserId());
	}

	public String viewAuditingUser(DBConnection con) throws Exception {
		return Value.view(getAuditingUser());
	}

	public String viewAuditingTime(DBConnection con) throws Exception {
		return Value.view(getAuditingTime());
	}

	public String viewAuditingStatus(DBConnection con) throws Exception {
		return Value.view(getAuditingStatus());
	}

	public String viewEnabledTime(DBConnection con) throws Exception {
		return Value.view(getEnabledTime());
	}

	public String viewStatus(DBConnection con) throws Exception {
		return Value.view(getStatus());
	}

	protected ProductUpdatePriceBase() {
	}

	public void fill(ProductUpdatePricePageData pageData) throws Exception {

		if (pageData.getId() != null) {
			setId(pageData.getId());
		}

		if (pageData.getProductId() != null) {
			setProductId(pageData.getProductId());
		}

		if (pageData.getConcentricityCode() != null) {
			setConcentricityCode(pageData.getConcentricityCode());
		}

		if (pageData.getBeforePrice() != null
				&& !pageData.getBeforePrice().equals("")) {
			setBeforePrice(Double.parseDouble(pageData.getBeforePrice()));
		}

		if (pageData.getAfterPrice() != null
				&& !pageData.getAfterPrice().equals("")) {
			setAfterPrice(Double.parseDouble(pageData.getAfterPrice()));
		}

		if (pageData.getCreateUserId() != null) {
			setCreateUserId(pageData.getCreateUserId());
		}

		if (pageData.getCreateUser() != null) {
			setCreateUser(pageData.getCreateUser());
		}

		if (pageData.getCreateTime() != null) {
			setCreateTime(pageData.getCreateTime());
		}

		if (pageData.getAuditingUserId() != null) {
			setAuditingUserId(pageData.getAuditingUserId());
		}

		if (pageData.getAuditingUser() != null) {
			setAuditingUser(pageData.getAuditingUser());
		}

		if (pageData.getAuditingTime() != null) {
			setAuditingTime(pageData.getAuditingTime());
		}

		if (pageData.getAuditingStatus() != null) {
			setAuditingStatus(pageData.getAuditingStatus());
		}

		if (pageData.getEnabledTime() != null) {
			setEnabledTime(pageData.getEnabledTime());
		}

		if (pageData.getStatus() != null) {
			setStatus(pageData.getStatus());
		}

	}

	public String getTableName() {
		return TABLE_NAME;
	}

	public String getBackupTableName() {
		return BACKUP_TABLE_NAME;
	}

	public String getBackupSeqName() {
		return BACKUP_SEQ_NAME;
	}

	public java.util.Vector getFields() {
		if (m_fields == null) {
			m_fields = new Vector();

			m_fields.add(new Field(ID, Value.TYPE_STRING, false, true, 32, "序号"));

			m_fields.add(new Field(PRODUCT_ID, Value.TYPE_STRING, false, true,
					32, "产品序号"));

			m_fields.add(new Field(CONCENTRICITY_CODE, Value.TYPE_STRING,
					false, true, 20, "集中编码"));

			m_fields.add(new Field(BEFORE_PRICE, Value.TYPE_DOUBLE, false,
					true, 0, "调价前价格"));

			m_fields.add(new Field(AFTER_PRICE, Value.TYPE_DOUBLE, false, true,
					0, "调价后价格"));

			m_fields.add(new Field(CREATE_USER_ID, Value.TYPE_STRING, false,
					true, 32, "创建人序号"));

			m_fields.add(new Field(CREATE_USER, Value.TYPE_STRING, false, true,
					50, "创建人"));

			m_fields.add(new Field(CREATE_TIME, Value.TYPE_STRING, false, true,
					20, "创建时间"));

			m_fields.add(new Field(AUDITING_USER_ID, Value.TYPE_STRING, false,
					true, 32, "审批人序号"));

			m_fields.add(new Field(AUDITING_USER, Value.TYPE_STRING, false,
					true, 50, "审批人"));

			m_fields.add(new Field(AUDITING_TIME, Value.TYPE_STRING, false,
					true, 20, "审批时间"));

			m_fields.add(new Field(AUDITING_STATUS, Value.TYPE_STRING, false,
					true, 2, "审批状态"));

			m_fields.add(new Field(ENABLED_TIME, Value.TYPE_STRING, false,
					true, 20, "启用时间"));

			m_fields.add(new Field(STATUS, Value.TYPE_STRING, false, true, 2,
					"是否启用"));

		}
		return m_fields;
	}

	public void initObject(java.sql.ResultSet rs) throws Exception {

		m_id = getString(rs, ID);

		m_status = getString(rs, STATUS);

		m_product_id = getString(rs, PRODUCT_ID);

		m_concentricity_code = getString(rs, CONCENTRICITY_CODE);

		m_before_price = getDouble(rs, BEFORE_PRICE);

		m_after_price = getDouble(rs, AFTER_PRICE);

		m_create_user_id = getString(rs, CREATE_USER_ID);

		m_create_user = getString(rs, CREATE_USER);

		m_create_time = getString(rs, CREATE_TIME);

		m_auditing_user_id = getString(rs, AUDITING_USER_ID);

		m_auditing_user = getString(rs, AUDITING_USER);

		m_auditing_time = getString(rs, AUDITING_TIME);

		m_auditing_status = getString(rs, AUDITING_STATUS);

		m_enabled_time = getString(rs, ENABLED_TIME);

		ms_new_flag = ConstDefine.NO;
	}

	public Value get(String f) {

		if (f.equalsIgnoreCase(ID)) {
			return new Value(getId());
		}

		if (f.equalsIgnoreCase(PRODUCT_ID)) {
			return new Value(getProductId());
		}

		if (f.equalsIgnoreCase(CONCENTRICITY_CODE)) {
			return new Value(getConcentricityCode());
		}

		if (f.equalsIgnoreCase(BEFORE_PRICE)) {
			return new Value(getBeforePrice());
		}

		if (f.equalsIgnoreCase(AFTER_PRICE)) {
			return new Value(getAfterPrice());
		}

		if (f.equalsIgnoreCase(STATUS)) {
			return new Value(getStatus());
		}

		if (f.equalsIgnoreCase(CREATE_USER_ID)) {
			return new Value(getCreateUserId());
		}

		if (f.equalsIgnoreCase(CREATE_USER)) {
			return new Value(getCreateUser());
		}

		if (f.equalsIgnoreCase(CREATE_TIME)) {
			return new Value(getCreateTime());
		}

		if (f.equalsIgnoreCase(AUDITING_USER_ID)) {
			return new Value(getAuditingUserId());
		}

		if (f.equalsIgnoreCase(AUDITING_USER)) {
			return new Value(getAuditingUser());
		}

		if (f.equalsIgnoreCase(AUDITING_TIME)) {
			return new Value(getAuditingTime());
		}

		if (f.equalsIgnoreCase(AUDITING_STATUS)) {
			return new Value(getAuditingStatus());
		}

		if (f.equalsIgnoreCase(ENABLED_TIME)) {
			return new Value(getEnabledTime());
		}

		return null;
	}

	public void set(String f, Value v) throws Exception {

		if (f.equalsIgnoreCase(ID)) {
			setId(v.getString());
		}

		if (f.equalsIgnoreCase(PRODUCT_ID)) {
			setProductId(v.getString());
		}

		if (f.equalsIgnoreCase(CONCENTRICITY_CODE)) {
			setConcentricityCode(v.getString());
		}

		if (f.equalsIgnoreCase(BEFORE_PRICE)) {
			setBeforePrice(v.getDouble());
		}

		if (f.equalsIgnoreCase(AFTER_PRICE)) {
			setAfterPrice(v.getDouble());
		}

		if (f.equalsIgnoreCase(STATUS)) {
			setStatus(v.getString());
		}

		if (f.equalsIgnoreCase(CREATE_USER_ID)) {
			setCreateUserId(v.getString());
		}

		if (f.equalsIgnoreCase(CREATE_USER)) {
			setCreateUser(v.getString());
		}

		if (f.equalsIgnoreCase(CREATE_TIME)) {
			setCreateTime(v.getString());
		}

		if (f.equalsIgnoreCase(AUDITING_USER_ID)) {
			setAuditingUserId(v.getString());
		}

		if (f.equalsIgnoreCase(AUDITING_USER)) {
			setAuditingUser(v.getString());
		}

		if (f.equalsIgnoreCase(AUDITING_TIME)) {
			setAuditingTime(v.getString());
		}

		if (f.equalsIgnoreCase(AUDITING_STATUS)) {
			setAuditingStatus(v.getString());
		}

		if (f.equalsIgnoreCase(ENABLED_TIME)) {
			setEnabledTime(v.getString());
		}
	}

	public String toString() {
		String msg = "ProductUpdatePrice=\n";
		msg += "(\r\n";

		msg += "    序号(id)=" + get("id") + "\r\n";

		msg += "    产品序号(product_id)=" + get("product_id") + "\r\n";

		msg += "    集中编码(concentricity_code)=" + get("concentricity_code")
				+ "\r\n";

		msg += "    调价前价格(before_price)=" + get("before_price") + "\r\n";

		msg += "    调价后价格(after_price)=" + get("after_price") + "\r\n";

		msg += "    创建人序号(create_user_id)=" + get("create_user_id") + "\r\n";

		msg += "    创建人(create_user)=" + get("create_user") + "\r\n";

		msg += "    创建时间(create_time)=" + get("create_time") + "\r\n";

		msg += "    审批人序号(auditing_user_id)=" + get("auditing_user_id")
				+ "\r\n";

		msg += "    审批人(auditing_user)=" + get("auditing_user") + "\r\n";

		msg += "    审批时间(auditing_time)=" + get("auditing_time") + "\r\n";

		msg += "    审批状态(auditing_status)=" + get("auditing_status") + "\r\n";

		msg += "    启用时间(enabled_time)=" + get("enabled_time") + "\r\n";

		msg += "    是否启用(status)=" + get("status") + "\r\n";

		msg += ")\r\n";
		return msg;
	}

	public void copyBase(ProductUpdatePriceBase srcObj) {

		setId(srcObj.getId());

		setProductId(srcObj.getProductId());

		setConcentricityCode(srcObj.getConcentricityCode());

		setBeforePrice(srcObj.getBeforePrice());

		setAfterPrice(srcObj.getAfterPrice());

		setCreateUserId(srcObj.getCreateUserId());

		setCreateUser(srcObj.getCreateUser());

		setCreateTime(srcObj.getCreateTime());

		setAuditingUserId(srcObj.getAuditingUserId());

		setAuditingUser(srcObj.getAuditingUser());

		setAuditingTime(srcObj.getAuditingTime());

		setAuditingStatus(srcObj.getAuditingStatus());

		setEnabledTime(srcObj.getEnabledTime());

		setStatus(srcObj.getStatus());

	}

	public String toXml() throws Exception {
		String xml = "";
		xml += "<ProductUpdatePrice>";

		xml += "<Id>" + Value.view(getId()) + "</Id>";

		xml += "<ProductId>" + Value.view(getProductId()) + "</ProductId>";

		xml += "<ConcentricityCode>" + Value.view(getConcentricityCode())
				+ "</ConcentricityCode>";

		xml += "<BeforePrice>" + Value.view(getBeforePrice())
				+ "</BeforePrice>";

		xml += "<AfterPrice>" + Value.view(getAfterPrice()) + "</AfterPrice>";

		xml += "<CreateUserId>" + Value.view(getCreateUserId())
				+ "</CreateUserId>";

		xml += "<CreateUser>" + Value.view(getCreateUser()) + "</CreateUser>";

		xml += "<CreateTime>" + Value.view(getCreateTime()) + "</CreateTime>";

		xml += "<AuditingUserId>" + Value.view(getAuditingUserId())
				+ "</AuditingUserId>";

		xml += "<AuditingUser>" + Value.view(getAuditingUser()) + "</AuditingUser>";

		xml += "<AuditingTime>" + Value.view(getAuditingTime()) + "</AuditingTime>";
		
		xml += "<AuditingStatus>" + Value.view(getAuditingStatus()) + "</AuditingStatus>";
		
		xml += "<EnabledTime>" + Value.view(getEnabledTime()) + "</EnabledTime>";

		xml += "<Status>" + Value.view(getStatus()) + "</Status>";

		xml += "</ProductUpdatePrice>";
		return xml;
	}

}
